﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemo._01_核心
{

    public enum TimeOfDay
    {
        Morning = 0,
        Afternoon = 1,
        Evening = 2
    }

    #pragma warning disable
    public class helloWorld
    {
        static int i = 5;
        static void main()
        {
            firstParagram();
            testVariable();
            testSentence();
            testEnum();
            testWriteLine();
            Pre.TestPre();
            Console.ReadLine();
            return;
        }

        public static void firstParagram()
        {
            Console.WriteLine("Hello World");
        }
        public static void testVariable()
        {
            //局部变量可以覆盖类级变量 
            int i = 10;
            Console.WriteLine("i:" + i);

            //常量必须初始化为确定的值
            const int a = 1;
            const int b = a;

            /********数据类型********/
            //1.有符号的整形
            sbyte i1 = 1;
            short i2 = 2;
            int i3 = 4;
            long i4 = 8;

            //2.无符号的整形
            byte u1 = 1;
            ushort u2 = 2;
            uint u3 = 4;
            ulong u4 = 8L;

            //3.浮点
            float f1 = 3.14f;
            double f2 = 4.14;

            //4.decimal
            decimal d1 = 3.140M;

            //5.字符类型
            char c1 = 'A';

            //6.引用类型
            Object o1 = new Object();
            string s1 = "Hello World";
            s1 = @"hello
                   world";
            Console.WriteLine("s1:" + s1);

        }

        public static void testSentence()
        {
            //if语句
            if ("helloWorld".Length > 1)
            {
                Console.WriteLine("if");
            }
            else
            {
                Console.WriteLine("else");
            }

            //switch语句 case不能贯穿
            string myCity = "wuhan";
            string myTip = "";
            switch (myCity)
            {
                case "beijing": myTip = "hello beijing"; break;
                case "wuhan": myTip = "hello wuhan"; break;
                default: myTip = "Shit"; break;
            }
            Console.WriteLine("myCity:" + myTip);


            //for循环
            int count = 0;
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.Write(count + " ");
                    count++;
                }
                Console.WriteLine();
            }

            //while循环
            int conditon = 0;
            while (conditon < 10)
            {
                Console.Write(conditon + " ");
                conditon++;
            }

            //foreach迭代
            int[] a = { 11, 12, 13, 14, 15 };
            foreach (int value in a)
            {
                Console.WriteLine(value);
            }
        }

        public static void testEnum()
        {
             //测试枚举类型
            TimeOfDay time = TimeOfDay.Afternoon;
            Console.WriteLine(time);
        }


        public static void  testWriteLine(){
            //format形式输出
            Console.WriteLine("{0}是一名{1}", "我", "程序员");

            //指定宽度和对齐方式
            for (int i = 15; i > 4; i--) {
                Console.WriteLine("{0,3}", i);
            }
        }


    }
}
